import router from './router';
import store from './store';
import Common from '@/js/common.js';
const whiteList = ['login', 'resetPwd', 'charts'];

router.beforeEach(async (to, from, next) => {
  // const hasToken = sessionStorage.token;
  // const accountDataInfo = Common.getCookie('accountDataInfo') && JSON.parse(Common.getCookie('accountDataInfo'))
  // const hasToken = (accountDataInfo && accountDataInfo.token) || sessionStorage.token;
  // let pathName = to.name || to.path.split('/')[1];
  // if (hasToken) {
  //   sessionStorage.userName = (accountDataInfo && accountDataInfo.userName) || sessionStorage.userName;
  //   sessionStorage.userId = (accountDataInfo && accountDataInfo.userId) || sessionStorage.userId;
  //   sessionStorage.roleName = accountDataInfo.roleName;
  //   sessionStorage.projectId = accountDataInfo.projectId || sessionStorage.projectId;
  //   sessionStorage.mobile = accountDataInfo.mobile;
  //   if (to.path === "/login") {
  //     // 若已登录返回首页
  //     next({ path: "/" });
  //   } else {
  //     if (store.state.getPermission) {
  //       // 已设置权限动态路由
  //       next();
  //     } else {
  //       next();
  //     }
  //   }
  // } else {
  //   if (whiteList.includes(pathName)) {
      next();
  //   } else {
  //     next({ name: 'login' });
  //   }
  // }
});
